package com.dhcc.bpm.modules.log.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.modules.log.entity.Tps;
import com.dhcc.bpm.modules.log.mapper.TpsMapper;
import com.dhcc.bpm.modules.log.service.ITpsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dhcc.bpm.modules.log.vo.GatewayLogDayVO;
import com.dhcc.bpm.modules.log.vo.TpsModelVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * tps管理表 服务实现类
 * </p>
 *
 * @author xiafayu
 * @since 2021-05-31
 */
@Service
public class TpsServiceImpl extends ServiceImpl<TpsMapper, Tps> implements ITpsService {

    @Override
    public IPage<TpsModelVO> selectTpsPage(IPage<TpsModelVO> page, TpsModelVO tpsVO) {
        return page.setRecords(baseMapper.selectTpsPage(page, tpsVO));
    }

    @Override
    public List<Tps> getList(String apiCode, String tpsDate) {
        return baseMapper.getList(apiCode, tpsDate);
    }

    @Override
    public List<String> getApiCodeList(String tpsDate) {
        return baseMapper.getApiCodeList(tpsDate);
    }

    @Override
    public List<Tps> getDayALlTpsPeak(String tpsDate) {
        return baseMapper.getDayALlTpsPeak(tpsDate);
    }

    @Override
    public List<TpsModelVO> getHourList(GatewayLogDayVO gatewayLogDayVO) {
        return baseMapper.getHourList(gatewayLogDayVO);
    }

    @Override
    public List<TpsModelVO> getDayList(GatewayLogDayVO gatewayLogDayVO) {
        return baseMapper.getDayList(gatewayLogDayVO);
    }

    @Override
    public int deleteTpsByDate(String tpsDate) {
        return baseMapper.deleteTpsByDate(tpsDate);
    }

    @Override
    public long queryTpsByDate(String reqDate, List<String> apiCodeList) {
        List<Tps> list = baseMapper.queryTpsByDate(reqDate, apiCodeList);
        if(list.size() > 0){
            return list.get(0).getTps();
        }
        return 0;
    }
}
